#include "character.h"
#include"config.h"
character::character()
{//初始化加载飞机图片
    duola.load(character_path);
    //初始化飞机坐标
    m_x=duola.width()/4;
    m_y=(game_height-duola.height())*0.5;

    //初始化矩形边框
    rect.setWidth(duola.width());
    rect.setHeight(duola.height());
    rect.moveTo(m_x,m_y);
}
void character::setposition(int x, int y)
{m_x=x;
    m_y=y;
       rect.moveTo(m_x,m_y);
}

void character::shoot()
{recorder++;
    //记录时间间隔
    if(recorder<=BULLET_INTERVAL)
{
        return;
    }//未到达发射间隔

    recorder=0;
    for(int i=0;i<BULLET_NUM;i++)
{if(m_bullets[i].free)
        {m_bullets[i].free=false;
        m_bullets[i].x=m_x+60;
        m_bullets[i].y=m_y+30;//可添加三个子弹！！！
        break;}//子弹可以发射
    }


}




